$(function() {
    let load = axios.create({
        baseURL: "http://localhost:3000/static/data/"

    })
    $(".rightbtn li").eq(4).on("click", function() {
        document.documentElement.scrollTop = 0
        console.log("566");
    })

    function loadListData() {
        let options = {
            url: "/ind.json"
        }
        load(options)
            .then((res) => {

                var data = res.data




                for (let i = 0; i < data[2].data.length; i++) {


                    $(".good1").append(` <div class="a2 b${i}">
                        <img src=" ${data[2].data[i].majorPics}" alt="">
                        <p class="productname">${data[2].data[i].name}</p>
                        <p><span class="jianyi">官方建议零售价 </span><span class="price">￥${data[2].data[i].price}</span></p>
                          <P class="vipp">
                         <span class="sp1">登录</span>
                         <span class="sp2">注册</span>
                         <b class="sp3">即可享受会员价</b>
                         </P>
                    </div>`);
                }
                for (let i = 0; i < data[4].data.length; i++) {


                    $(".good2").append(` <div  class="a4 b${i}">
                        <img src=" ${data[4].data[i].pic}" alt="">
                        <p class="productname">${data[4].data[i].name}</p>
                        <p><span class="jianyi">官方建议零售价 </span><span class="price">￥${data[4].data[i].price}</span></p>
                         <P class="vipp">
                         <span class="sp1">登录</span>
                         <span class="sp2">注册</span>
                         <b class="sp3">即可享受会员价</b>
                         </P>
                    </div>`);
                }
                for (let i = 0; i < data[6].data.length; i++) {


                    $(".good3").append(` <div  class="a6 b${i}">
                        <img src=" ${data[6].data[i].pic}" alt="">
                        <p class="productname">${data[6].data[i].name}</p>
                        <p><span class="jianyi">官方建议零售价 </span><span class="price">￥${data[6].data[i].price}</span></p>
                         <P class="vipp">
                         <span class="sp1">登录</span>
                         <span class="sp2">注册</span>
                         <b class="sp3">即可享受会员价</b>
                         </P>
                    </div>`);
                }
                for (let i = 0; i < data[8].data.length; i++) {


                    $(".good4").append(` <div  class="a8  b${i}">
                    
                        <img src=" ${data[8].data[i].pic}" alt="">
                        <p class="productname">${data[8].data[i].name}</p>
                        <p><span class="jianyi">官方建议零售价 </span><span class="price">￥${data[8].data[i].price}</span></p>
                         <P class="vipp">
                         <span class="sp1">登录</span>
                         <span class="sp2">注册</span>
                         <b class="sp3">即可享受会员价</b>
                         </P>
                    </div>`);
                }
                let TOKEN = cookie("TOKEN")

                if (TOKEN.length > 0) {
                    $(".vipp").addClass("hide")
                } else {
                    console.log("没有");
                }




                // 楼梯层效果
                $(".leftbtn li").each(function(i, item) {
                        var arr = [1000, 2820, 4620, 6440]
                        item.onclick = function() {
                            document.documentElement.scrollTop = arr[i]
                                // 
                        }
                    })
                    // $(".leftbtn li").each(function (i, item) {
                    //     item.onclick = function () {
                    //         // document.documentElement.scrollTop  = $(".congoods p").eq(i).offset().top
                    //      
                    //         console.log($(".congoods p").eq(i).offsetparent().top);
                    //     }
                    // })
                var $tz = $(".box>div")
                $tz.each(function(i, item) {
                    $(item).on("click", function() {
                        // console.log($(item).attr("class"));
                        location.href = "./detial.html" + "#" + $(item).attr("class")

                    })
                })
            });
    }

    loadListData();

})